package com.pxst.amq;

import java.util.Map;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pxst.sys.entity.SysLog;
import com.pxst.sys.service.SysLogService;

import lombok.extern.slf4j.Slf4j;

/** 
 * 操作日志消费者
* @author yangxy
* @version 创建时间：2023年9月19日 上午11:02:18 
*/
@Slf4j
@Component
public class OperateLogConsumer {
	@Autowired
	private SysLogService sysLogService;
	
	@RabbitListener(queues = "#{operateLogQueue.name}",concurrency = "10")
	public void listener(String message) {
		log.info("操作日志队列监听：{}",message);
		JSONObject parseObject = JSON.parseObject(message);
		SysLog sysLog = JSON.toJavaObject(parseObject, SysLog.class);
		sysLogService.save(sysLog);
	}
}
